<template>
  <div class="container">
    <div class="content">
      <button
        v-for="(btn, index) in buttons"
        :key="index"
        :class="['panel-button', btn.color, btn.wrap]"
        @click="handleButtonClick(btn.action)"
      >
        {{ btn.label }}
      </button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      buttons: [
        { label: "警报器", action: "alarm", color: "white", wrap: "wrap" },
        { label: "自动/手动", action: "mode", color: "white" },
        { label: "联动启动", action: "linkage", color: "white" },
        { label: "信息确认", action: "confirm", color: "white" },
        { label: "自检", action: "self-check", color: "white" },
        { label: "消音", action: "mute", color: "yellow" },
        { label: "复位", action: "reset", color: "orange" },
        { label: "检查", action: "inspect", color: "red" },
      ],
    };
  },
  methods: {
    handleButtonClick(action) {
      this.$emit("button-click", action);
      console.log("Button clicked:", action);
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  width: 100%;
  height: 100%;
  padding: 16px 0;
  box-sizing: border-box;
}

.content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;

  .panel-button {
    width: 42px;
    height: 40px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;

    // 立体效果 - 底部阴影
    &::before {
      content: "";
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 2%;
      background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.2),
        rgba(0, 0, 0, 0.4)
      );
      border-radius: 0 0 6px 6px;
      transition: all 0.2s ease;
    }

    // 按下效果
    &:active {
      //   transform: translateY(2px);
      transform: scale(0.95);
      &::before {
        height: 5%;
      }
    }

    // 不同颜色按钮
    &.white {
      background-color: #f0f0f0;
      color: #333;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 2px 8px rgba(0, 0, 0, 0.4);
    }

    &.yellow {
      background-color: #ffeb3b;
      color: #333;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6),
        0 2px 8px rgba(0, 0, 0, 0.4);
    }

    &.orange {
      background-color: #ff9800;
      color: #fff;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.4);
    }

    &.red {
      background-color: #f44336;
      color: #fff;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.4);
    }
  }

  .wrap {
    white-space: nowrap !important;
  }
}
</style>